#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([open-wars], [0.1], [tim.sarbin@gmail.com])
AC_CONFIG_SRCDIR([src/main.cc])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET


AX_CHECK_GL
if [test ! "$GL_LIBS"]
then
	CXXFLAGS="$CXXFLAGS -framework GLUT -framework OpenGL -framework Carbon -lobjc -framework IOKit -framework CoreFoundation -DIS_OSX"
	AC_CHECK_HEADERS([/opt/local/include/libpng14/png.h],,[AC_MSG_FAILURE([libpng development support not found.])])
	CXXFLAGS="$CXXFLAGS -I/usr/include `pkg-config libpng freetype2 zlib lua5.1 --cflags`"
	LDFLAGS="$LDFLAGS -L/opt/local/lib `pkg-config libpng freetype2 zlib lua5.1 --libs`"
else
	CXXFLAGS="$CXXFLAGS $GL_CFLAGS  -I/usr/include `pkg-config libpng lua5.1 freetype2 zlib --cflags`"
	LIBS="$LIBS $GL_LIBS"
	LDFLAGS="$LDFLAGS `pkg-config libpng freetype2 zlib lua5.1 --libs` -lglut"

	# Checks for header files.
	AC_CHECK_HEADERS([GL/gl.h],,[AC_MSG_FAILURE([OpenGL development support not found.])])
	AC_CHECK_HEADERS([GL/freeglut.h],,[AC_MSG_FAILURE([FreeGLUT development support not found.])])
	AC_CHECK_HEADERS([png.h],,[AC_MSG_FAILURE([libpng development support not found.])])
fi




# Checks for libraries.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile
                 src/Makefile
                 media/Makefile
                 media/cursor/Makefile])
AC_OUTPUT
